stage.set_background("schoolentrance")
stage.wait(2)
stage.create_grid_overlay(50, "blue")
stage.set_background_color("azure")
emma = codesters.Sprite("person1")
emma.set_size(0.5)
michael = codesters.Sprite("person2")
michael.set_size(0.5)
emma_x = random.randint(-230,230)
emma_y = random.randint(-230,230)
emma.go_to(emma_x, emma_y)
michael_x = random.randint(-230,230)
michael_y = random.randint(-230,230)
michael.go_to(michael_x, michael_y)
delta_x = emma_x - michael_x
delta_y = emma_y - michael_y
distance = math.sqrt((delta_x**2) + (delta_y**2))
if distance <= 200:
# add your code here
emma.say("I am a sprite.")
emma.load_image("person1_masked")
michael.load_image("person2_masked")
t = codesters.Teacher()
says = t.find_text("say")
elses = t.find_text("else:")
try:
else_line = elses[0][0]
else_indent = t.get_indent_at_line(else_line)
except:
else_line = "DNE"
else_indent = "DNE"
try:
tval1 = says[1][0]
tval1a = t.get_indent_at_line(tval1)
except:
tval1 = "DNE"
tval1a = "DNE"
try:
tval2 = says[1][1].replace(" ", "")
except:
tval2 = "DNE"
t1 = TestObjective()
t1.add_success("michael" in tval2, "Great job!")
t1.add_failure("michael" not in tval2, "Did you change the name in front of .say() to michael?")
t2 = TestObjective()
t2.add_success(tval1a == 4, "Great job!")
t2.add_failure(tval1a == "DNE", "Did you drag out a Say tool and change the name in front of it to michael?")
t2.add_failure(tval1a < 4, "Did you remember to indent .say()?")
t2.add_failure(tval1a > 4, "Oops! Did you indent .say() more than 4 spaces?")
t3 = TestObjective()
t3.add_failure(else_indent == "DNE", "Oops! Did you add an else statement?")
t3.add_success(else_indent == 0, "Great job!")
t3.add_failure(else_indent > 0, "Oops! Did you indent your else statement?")
tester = TestManager()
tester.add_test_list([t3, t2, t1])
tester.run_tests()
tester.display_first_feedback()
Are you already running a Codesters project in another tab or window?
Micro:bit can only connect to one web page at a time.
Try stopping other Codesters projects or closing
other tabs or windows that may be using your Micro:bit.
If that doesn't fix the problem try disconnecting your Micro:bit,
reloading this page, and reconnecting your Micro:bit.